from django.db import models
from dvadmin.utils.models import CoreModel

class Order(CoreModel):
    """订单模型"""
    ORDER_STATUS = (
        (1, '待处理'),
        (2, '处理中'),
        (3, '已完成'),
        (4, '已取消')
    )
    
    order_number = models.CharField(max_length=50, unique=True, verbose_name="订单编号")
    customer_name = models.CharField(max_length=100, verbose_name="客户名称")
    product = models.CharField(max_length=100, verbose_name="产品名称")
    quantity = models.IntegerField(verbose_name="订单数量")
    order_date = models.DateField(verbose_name="下单日期")
    delivery_date = models.DateField(verbose_name="交付日期")
    status = models.IntegerField(choices=ORDER_STATUS, default=1, verbose_name="订单状态")
    priority = models.IntegerField(verbose_name="优先级", default=1)
    total_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="订单金额")
    sales_person = models.CharField(max_length=100, verbose_name="销售人员", null=True, blank=True)
    remarks = models.TextField(verbose_name="备注", null=True, blank=True)

    def __str__(self):
        return self.order_number

    class Meta:
        db_table = "order"
        verbose_name = '订单管理'
        verbose_name_plural = verbose_name
        ordering = ('-create_datetime',)
